package cn.edu360.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu360.pojo.Bike;
import cn.edu360.service.BikeService;

/**
 * 标记这个类是一个用于介绍请求和相应用户的一个控制器
 * 加上@Controller注解后，Sring容器就行对他实例化
 * @author 梁聚威
 *
 */
@Controller
public class BikeController {
	
	//到sring容器中，查找BikeService类型的实例，然后注入到BikeController实例中
	@Autowired
	private BikeService bikeService;
	
	@RequestMapping("/bike/add")
	@ResponseBody
	public String add(@RequestBody Bike bike) {
		//调用service层，将数据保存到mongodb中
		bikeService.save(bike);
		return "success";
	}
}
